import 'package:bloc/bloc.dart';
import 'package:qgchat/http/apis/common.dart';
import 'package:qgchat/http/models/commentListModel.dart';

enum CommentEvent { refresh }

class CommentBloc extends Bloc<CommentEvent, List<CommentListModel>> {
  CommentBloc(this.id);

  final int id; // 评论id
  
  @override
  List<CommentListModel> get initialState => List<CommentListModel>();

  @override
  Stream<List<CommentListModel>> mapEventToState(CommentEvent event) async* {
    switch (event) {
      // 刷新
      case CommentEvent.refresh:
        List<CommentListModel> info = await CommonApis.commentList(id);
        yield info.map((i) => i).toList();
        break;
    }
  }

}